var t = require("../../../@babel/runtime/helpers/objectWithoutProperties"), a = [ "url" ], e = getApp();

Page({
    data: {
        list: [],
        logo_url: "",
        last_page: "",
        finished: !1,
        current_page: 1,
        plugin: "message-base",
        itemOption: {
            image: "image_url",
            name: "name",
            desc: "desc"
        }
    },
    onLoad: function(t) {
        this.init(), this.getData();
    },
    onReady: function() {},
    toUrl: function(t) {
        var a = t.currentTarget.dataset || {};
        this.wxRouterLink(a);
    },
    wxRouterLink: function(e) {
        var n = "", i = e.url, s = t(e, a);
        Object.keys(s).forEach(function(t) {
            "" !== s[t] && (n += t + "=" + s[t] + "&");
        }), "" !== i && wx.navigateTo({
            url: i + "?" + n.slice(0, -1)
        });
    },
    init: function() {
        var t = this;
        this.data.list = [], this.data.current_page = 1, this.data.finished = !1;
        var a = new Map([ [ "message-base", {
            index: "plugin.message-base.frontend.base.index",
            params: function() {
                return {
                    page: t.data.current_page
                };
            },
            callback: function(a) {
                t.data.current_page += 1;
                var e = a.data, n = e.data, i = e.logo, s = e.current_page, o = e.last_page;
                t.setData({
                    logo_url: i,
                    list: t.data.list.concat(n)
                }), s >= o && (t.data.finished = !0);
            }
        } ], [ "project-template", {
            index: "plugin.project-template.frontend.knowledge.knowledgeBaseList",
            params: function() {
                return {
                    page: t.data.current_page
                };
            },
            callback: function(a) {
                t.data.current_page += 1;
                var e = a.data, n = e.data;
                e.current_page >= e.last_page && (t.data.finished = !0), t.setData({
                    itemOption: {
                        image: "banner",
                        name: "title",
                        desc: "content"
                    },
                    list: t.data.list.concat(n)
                });
            }
        } ] ]);
        this.options.plu && this.setData({
            plugin: this.options.plu
        }), this.data.apiOption = a.get(this.data.plugin);
    },
    getData: function() {
        var t = this;
        if (!this.data.finished) {
            var a = e.getNetAddresss(this.data.apiOption.index);
            e._getNetWork({
                url: a,
                data: this.data.apiOption.params(),
                success: function(a) {
                    1 === a.data.result ? t.data.apiOption.callback(a.data) : wx.showToast({
                        title: a.data.msg,
                        icon: "none"
                    });
                }
            });
        }
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getData();
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), {
            path: "/packageI/knowledge/knowledgeList/knowledgeList?plu=" + this.options.plu + "&bid=" + this.options.bid + "&mid=" + a
        };
    }
});